package com.dhsc.service.impl.ywjk.cgyhjh;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhsc.domain.jkzx.ywjk.cgyhjh.TcgYcVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.domain.yypt.ResponseObject;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.ywjk.cgyhjh.ICgyclxwhDao;
import com.dhsc.service.ywjk.cgyhjh.ICgyclxwhService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: CgyclxwhServiceImpl
 * @Description: 存管异常类型维护
 * @Author: jwj
 * @Date: 2023/11/7 11:06
 */
@Service
@Slf4j
public class CgyclxwhServiceImpl implements ICgyclxwhService {

    @Autowired
    private ICgyclxwhDao cgyclxwhDao;

    @Override
    public LayuiTableVo queryCgyclx(TcgYcVo tcgYcVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try{
            PageMethod.startPage(tcgYcVo.getPage(), tcgYcVo.getLimit());
            List<TcgYcVo> list = cgyclxwhDao.queryCgyclx(tcgYcVo);
            PageInfo<TcgYcVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch(Exception e){
            log.error("存管异常类型维护查询出错", e);
            throw new MyException("存管异常类型维护查询出错",e);
        }
        return obj;
    }

    @Override
    public ResponseObject updateTcgYc(TcgYcVo tcgYcVo) {
        ResponseObject obj = new ResponseObject();
        try{
            cgyclxwhDao.updateTcgYc(tcgYcVo);
            obj.setStatus(200);
        }catch(Exception e){
            log.error("更新存管异常类型出错", e);
            throw new MyException("更新存管异常类型出错",e);
        }
        return obj;
    }

}
